package cn.itrip.controller;

import cn.itrip.commons.DtoUtils;
import cn.itrip.dto.Dto;
import cn.itrip.dto.HotelPageDTO;
import cn.itrip.service.SearchService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author Super God Jie
 * @version 1.0  2022-04-14 23:25
 */
@RestController
@RequestMapping("/api/hotellist")
public class SearchController {
	@Resource
	private SearchService searchService;

	@PostMapping("/searchItripHotelListByHotCity")
	public Dto hotelPage(@RequestBody Map<String,String> map){
		try {
			return DtoUtils.returnSuccess(searchService.searchItripHotelListByHotCity(map.get("cityId"),
					Integer.parseInt(map.get("count"))));
		} catch (Exception e) {
			return DtoUtils.returnFail("10003",e.getMessage());
		}
	}

	@PostMapping("/searchItripHotelPage")
	public Dto searchItripHotelPage(@RequestBody HotelPageDTO hotelPageDTO){
		try {
			return DtoUtils.returnSuccess(searchService.searchItripHotelPage(hotelPageDTO));
		} catch (Exception e) {
			return DtoUtils.returnFail("10002",e.getMessage());
		}
	}

}
